package com.cy.api;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
@interface Entity{
    String value()default "";
}

@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.FIELD,ElementType.METHOD})
@interface ID{
    String value()default "";
}

@Entity("t_user")
class User{
    @ID("uid")
    private Integer id;
}

public class AnnotationTests {
    public static void main(String[] args) throws NoSuchFieldException {
        Class<?> cls=User.class;
        System.out.println(cls.getAnnotation(Entity.class).value());
        System.out.println(cls.getDeclaredField("id").getAnnotation(ID.class).value());
    }
}
